package dbs;

import java.sql.*;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DataBaseConnection {
//    private String DBDRIVER = "com.microsoft.sqlserver.jdbc.SQLServerDriver";
//    private String DBURL = "jdbc:sqlserver://localhost:1433;DatabaseName=TEST";

    private String DBDRIVER = "com.mysql.cj.jdbc.Driver";
    private String DBURL = "jdbc:mysql://localhost:3306/train?serverTimezone=UTC";
    private String DBUSER = "root";
    private String DBPASSWORD = "root";
    private Connection conn = null;

    public DataBaseConnection() {
        try {
            Class.forName(DBDRIVER);
            this.conn = DriverManager.getConnection(DBURL, DBUSER, DBPASSWORD);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public Connection getConnection() {
        return this.conn;
    }


    public void close() {
        try {
            this.conn.close();
        } catch (SQLException e) {
            e.printStackTrace();
        }
    }

}
